/** 子路由，负责子模块的视图跳转，最后汇总到app.routes中。 */
import { NgModule } from '@angular/core';
import { Routes, RouterModule, PreloadAllModules } from '@angular/router';

import { DockComponent } from './dock.component';
import { NotFoundComponent } from '../shared/404.component';

import { AuthGuard } from '../shared/auth-guard.service';
import { CanDeactivateGuard } from '../shared/can-deactivate-guard.service';

export const routes: Routes = [
  {
    path: 'dock',
    component: DockComponent,
    children: [
      // { path: 'admin', loadChildren: () => AdminModule },
      { path: 'admin', loadChildren: 'app/dock/admin/admin.module#AdminModule', canLoad: [AuthGuard] },
      { path: 'home', loadChildren: 'app/dock/home/home.module#HomeModule', data: { preload: true } },
      { path: 'contact', loadChildren: 'app/dock/contact/contact.module#ContactModule' },
      { path: 'about', loadChildren: 'app/dock/about/about.module#AboutModule' },
      { path: 'demo', loadChildren: 'app/dock/demo/demo.module#DemoModule' },
      { path: '', pathMatch: 'full', redirectTo: '/dock/home' },
      { path: '**', component: NotFoundComponent }
    ]
  }
];

@NgModule({
  imports: [
    RouterModule.forChild(
      routes,
      // { preloadingStrategy: PreloadAllModules }
    )],
  exports: [RouterModule],
  providers: [
    AuthGuard,
    CanDeactivateGuard
  ]
})
export class DockRoutingModule { }
